package com.yaoxuguang.concurrence.threadBase.threadSafe;

/**
 * @author yaoxuguang
 * @Title: yao-interview
 * @Package com.yaoxuguang.concurrence.threadBase.threadSafe
 * @Description: 模拟一个登录的servlet组件
 * @date 2018年12月17日14:30
 */
public class LoginServlet {
    private static String usernameRef;
    private static String passwordRef;

    synchronized public static void doPost(String username,String password){
        try {
            usernameRef = username;
            if("a".equals(username.trim())){
                Thread.sleep(500);
            }
            passwordRef = password;
            System.out.println("username="+usernameRef+",password="+password);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
